Skip to content

Conversation

rlubos
Copy link
Contributor

@rlubos rlubos commented Oct 7, 2025

The main purpose of this PR is to add support for optional payload callback for CoAP client uploads. Additionally:

  • Fix block size negotiation for block transfer uploads
  • Add a new CoAP upload sample, showcasing various ways of uploading content.

Resolves #59571

rlubos added 2 commits October 7, 2025 13:54
During block uploads, the server may respond with Block 1 option with
a smaller block size than currently used (so called block size
negotiation). The CoAP client however did not read the Block 1 option
from the response, therefore ignoring the server request to lower the
block size.

Signed-off-by: Robert Lubos <[email protected]>
Add an optional payload callback field to the coap_client_request
structure, allowing the application to provide blocks of payload
interactively during the resource upload, instead of having to provide
entire payload in a single contigunous memory space.

If registered, the CoAP client library will call the payload callback
whenever a new PUT/POST message is being generated (note this is also
true for retransmissions) instead of using the payload pointer/length.
If the payload callback is NULL, then the library operates as usual.

Signed-off-by: Robert Lubos <[email protected]>
Add a new sample demonstrating various ways of performing CoAP uploads
with the CoAP Client library:
 * short uploads with payload pointer
 * short uploads with payload callback
 * block transfer uploads with payload pointer
 * block transfer uploads with payload callback

The resource names have been chosen so that the sample can run out of
the box against the Zephyr's CoAP server sample.

Signed-off-by: Robert Lubos <[email protected]>
rlubos added 2 commits October 8, 2025 09:16
Document the usage of the payload callback in the CoAP client
documentation page.

Signed-off-by: Robert Lubos <[email protected]>
Add release notes entry covering the new CoAP client payload callback.

Signed-off-by: Robert Lubos <[email protected]>
@rlubos rlubos force-pushed the net/coap-upload-cb branch from e2f2a01 to 7a8a65d Compare October 8, 2025 07:16
provide a single contiguous buffer with the entire payload. An example callback, providing the
content of the Lorem Ipsum string can look like this:

.. code-block:: c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to whine about this, but I dislike the fact that our code samples in the documentation do not adhere to our code style (tabs vs spaces). And it's an annoyance to do it properly, because rst file uses spaces for indentation, while our c code uses tabs.

I worked around this by using literalinclude:: directives instead of inline code, but that isn't ideal either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but that probably would need to be brought to a broader audience, it's everywhere like this from what I see, it's not only this file.

Copy link

sonarqubecloud bot commented Oct 8, 2025

@cfriedt cfriedt merged commit 9c49eaf into zephyrproject-rtos:main Oct 9, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking area: Samples Samples area: Sockets Networking sockets Release Notes To be mentioned in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

net: coap_client: streaming blockwise payloads

5 participants